package com.coocaa.ops.admin.v1.cornericon.validator;

import com.coocaa.ops.admin.base.language.CommonLanguageProperties;
import com.coocaa.ops.common.core.biz.cornericon.entity.GlobalCornerIconEntity;
import lombok.experimental.UtilityClass;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

/**
 * @author bijiahao
 * @description
 * @date 2020/6/22 16:46
 */
@Component
public class CornerIconValidator {

    private static CommonLanguageProperties commonLanguageProperties;

    public static void valid(GlobalCornerIconEntity entity) {
        Assert.notNull(entity.getTypeId(), "typeId " + commonLanguageProperties.getNotNull());
        Assert.hasText(entity.getImgUrl(), "imgUrl " + commonLanguageProperties.getNotNull());
        Assert.hasText(entity.getAttributeCode(), "attributeCode " + commonLanguageProperties.getNotNull());
    }

    @Autowired
    public void setCommonLanguageProperties(CommonLanguageProperties commonLanguageProperties) {
        CornerIconValidator.commonLanguageProperties = commonLanguageProperties;
    }

}
